<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>聚焦切换特效</title>
    <link rel="stylesheet" href="reset.css" />
    <style>
      html,
      body {
        width: 100%;
        height: 100%;
      }
      .panel {
        position: relative;
        width: 100%;
        height: 100%;
        background-color: black;
        display: none;
        overflow: hidden;
      }
      .circle {
        position: absolute;
        width: 100vw;
        height: 100vw;
        border-radius: 50%;
        left: 50vw;
        top: 50vh;
        transform: translate(-50%, -50%);
        background-color: white;
      }
      .focus {
        animation: 2s focus alternate 2;
      }
      @keyframes focus {
        0% {
          width: 100vw;
          height: 100vw;
        }
        100% {
          width: 100px;
          height: 100px;
          top: 100px;
        }
      }
    </style>
  </head>
  <body>
    <div class="panel">
      <div class="circle"></div>
    </div>
    <script>
      let panel = document.querySelector(".panel");
      let circle = document.querySelector(".circle");
      let timer1 = setTimeout(function () {
        panel.style.display = "block";
        circle.classList.add("focus");
        clearTimeout(timer1);
        let timer2 = setTimeout(function () {
          panel.style.display = "none";
          clearTimeout(timer2);
        }, 4000);
      }, 1000);
    </script>
  </body>
</html>
